package part5;

/**
 * @author wcj
 * @Date 2021/5/13 14:53
 * @Version 1.0
 */
public class Part51 {
    public static void main(String[] args) {
        Rock rock = new Rock();
        Rock rock2 = new Rock("wcj", 25);
        System.out.println("我是rock2:"+rock2);
    }

}

class Rock{

    private String name;

    private Integer age;

    /**
     * 无参构造器
     */
    public Rock() {
        System.out.println("我是Rock");
    }

    /**
     * 有参构造器
     * @param name
     * @param age
     */
    public Rock(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Rock{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
